///**
// * 
// */
//package cn.controller;
//
//import java.io.BufferedReader;
//import java.io.DataOutputStream;
//import java.io.IOException;
//import java.io.InputStreamReader;
//import java.io.UnsupportedEncodingException;
//import java.net.HttpURLConnection;
//import java.net.MalformedURLException;
//import java.net.URL;
//import java.net.URLConnection;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.UUID;
//
//import javax.servlet.http.HttpServletRequest;
//
//import net.sf.json.JSONArray;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
//
//import com.google.gson.Gson;
//
//import cn.model.Usertest;
//import cn.service.UserService;
//import cn.util.MD5Util;
//
///**
// * @author pc-Haitao
// * @ClassName:TestAction
// * @Version 版本
// * @Modifiedby 修改人
// * @Copyright 公司名称
// * @date 2016年8月25日上午9:12:43
// */
//@RestController
//@RequestMapping("/Test")
//public class TestAction {
//	@Autowired
//	private UserService iUserService;//注入接口
//
//	@RequestMapping(value = "/Action", method = { RequestMethod.POST, RequestMethod.GET })
//	public Map<String, Boolean> test(HttpServletRequest request) {
//		String s = request.getParameter("Name");
//		boolean b = iUserService.verifyByName(s);
//		Map<String, Boolean> map = new HashMap<String, Boolean>();
//		map.put("success", b);
//		return map;
//	}
//
//	@RequestMapping(value = "/Name", method = { RequestMethod.POST, RequestMethod.GET })
//	public Map<String, Object> save(String name, String pwd) {
//		System.out.println(name + "==" + pwd);
//		Usertest user = new Usertest();
//		user.setId(UUID.randomUUID().toString());// 使用uuid生成的32位id
//		user.setName(name);
//		user.setPassword(MD5Util.encode2hex(pwd));// 使用md5加密密码 
//		iUserService.save(user);
//		Map<String, Object> map = new HashMap<String, Object>();
//		map.put("user", user);
//		return map;
//	}
//	@RequestMapping(value = "/setJson", method = { RequestMethod.POST, RequestMethod.GET })
//	public int putJason(){
//		int i=0;
//		String sql="FROM Usertest u";
//		List<Usertest> userList=iUserService.find(sql,null);
//		Map<String,Object> map=new HashMap<String, Object>();
//		Map<String,String> map1=new HashMap<String, String>();
//		for(Usertest u:userList){
//			map1.put("id", u.getId());
//			map1.put("name", u.getName());
//			map1.put("password",u.getPassword());
//			map.put("list"+i, map1);
//			i++;
//		}
//		Map<String,Object> map2=new HashMap<String, Object>();
//		map2.put("ret", map);
//		String s = new Gson().toJson(map2);
//		System.out.println(s);
//		
//		 String ADD_URL = "http://10.4.4.181:8080/webService/getJson";
//		 URL url;
//		try {
//			url = new URL(ADD_URL);
//			 HttpURLConnection connection = (HttpURLConnection) url.openConnection();
//	         connection.setDoOutput(true);
//	         connection.setDoInput(true);
//	         connection.setRequestMethod("POST");
//	         connection.setUseCaches(false);
//	         connection.setInstanceFollowRedirects(true);
//	         connection.setRequestProperty("connection", "Keep-Alive");
//	         connection.connect();
//	         //POST请求
//	         DataOutputStream out = new DataOutputStream(
//	                 connection.getOutputStream());
//	         out.writeBytes(s);
//	         out.flush();
//	         out.close();
//	         connection.disconnect();
//		} catch (MalformedURLException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}catch (UnsupportedEncodingException e) {
//            e.printStackTrace();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//
//		return i;
//	}
//	
//	@RequestMapping(value = "/getJson", method = { RequestMethod.POST, RequestMethod.GET })
//	public void getJason(HttpServletRequest request) {
//		// StringBuffer json = new StringBuffer();
//		 String s = request.getParameter("ret");
//		 System.out.println(s);
//         /*try {
//        	 String s = request.getParameter("ret");
//        	 URL oracle = new URL("http://localhost:8080/webService/getJson");
//             //打开链接
//             URLConnection yc = oracle.openConnection();
//             //输入流作参数传进InputStreamReader并用BufferedReader接受
//             BufferedReader in = new BufferedReader(new InputStreamReader( yc.getInputStream()));
//             String inputLine = null;
//             //一直读到空，并设置流编码是UTF8
//             while ( (inputLine = in.readLine()) != null) {
//                 json.append(new String(inputLine.getBytes(),"GBK"));
//             }
//             //记得关闭连接
//             in.close();
//         } catch (Exception e)  {
//             e.printStackTrace();
//         }
//   */
//         //System.out.println(json.toString());
// 		
//
//		
//	}
//}
